package org.example.book.state.command;

import org.example.book.state.pojo.Order;
import org.springframework.stereotype.Component;

/**
 * 接受者角色
 *
 * @author jeff
 */
@Component
public class OrderCommandReceiver {

    public void action(Order order) {
        switch (order.getOrderState()) {
            case ORDER_WAIT_PAY:
                System.out.println("创建订单：order = " + order);
                System.out.println("存入db");
                return;
            case ORDER_WAIT_SEND:
                System.out.println("支付订单order = " + order);
                System.out.println("存入db");
                System.out.println("通过queue通知财务部门");
                System.out.println("通过queue通知物流部门");
                return;
            case ORDER_WAIT_RECEIVE:
                System.out.println("订单发货order = " + order);
                System.out.println("存入db");
                return;
            case ORDER_FINISH:
                System.out.println("接受订单order = " + order);
                System.out.println("存入db");
                return;
            default:
                throw new UnsupportedOperationException("order state err");
        }
    }
}
